<?phpnamespace App\Http\Middleware;use Closure;use Config , Cookie;class Auth{    /**     * Handle an incoming request.     *     * @param  \Illuminate\Http\Request  $request     * @param  \Closure  $next     * @param  string|null  $guard     * @return mixed     */    public function handle($request , Closure $next)    {        $token = Cookie::get(Config::get('session.user_cookie'));        if(!$token){            $token = $request->get('token');        }        $userInfo = \Cache::get($token);        if(!isset($userInfo->id)){            $loginUrl = Config::get('app.url').'/api/wechat/login?appid='.$request->get('appid');            return response()->json(['error' => '没有登录' , 'redirect' => [$loginUrl] ]);        }        global $g_uid;        global $g_openid;        $g_uid = $userInfo->id;        $g_openid = $userInfo->openid;        $response = $next($request);        return $response;    }}